//
//  JzyTools.m
//  jzyParents
//
//  Created by 任辰东 on 2022/4/30.
//

#import "JzyTools.h"

@implementation JzyTools

+(void)cachesUserInfo:(UserInfoModel *)userInfo
{
    NSString *userInfoStr = [[userInfo mj_keyValues] mj_JSONString];
    [[NSUserDefaults standardUserDefaults] setObject:userInfoStr forKey:kUserInfoKey];
}

+(UserInfoModel *)getUserInfo
{
    NSString *userInfoStr = [[NSUserDefaults standardUserDefaults] objectForKey:kUserInfoKey];
    UserInfoModel *userInfo = [UserInfoModel mj_objectWithKeyValues:[userInfoStr mj_keyValues]];
    return userInfo;
}

+(void)clearAllUserDefaultsData
{
    NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
    [[NSUserDefaults standardUserDefaults]removePersistentDomainForName:appDomain];

}

+(NSString *)dealGrade:(NSString *)grade
{
    NSString *gradeStr = @"一";
    switch (grade.integerValue) {
        case 1:
        {
            gradeStr = @"一年级";
        }
            break;
        case 2:
        {
            gradeStr = @"二年级";
        }
            break;
        case 3:
        {
            gradeStr = @"三年级";
        }
            break;
        case 4:
        {
            gradeStr = @"四年级";
        }
            break;
        case 5:
        {
            gradeStr = @"五年级";
        }
            break;
        case 6:
        {
            gradeStr = @"六年级";
        }
            break;
        case 7:
        {
            gradeStr = @"初一";
        }
            break;
        case 8:
        {
            gradeStr = @"初二";
        }
            break;
        case 9:
        {
            gradeStr = @"初三";
        }
            break;
        case 10:
        {
            gradeStr = @"高一";
        }
            break;
        case 11:
        {
            gradeStr = @"高二";
        }
            break;
        case 12:
        {
            gradeStr = @"高三";
        }
            break;
            
        default:
            break;
    }
    return gradeStr;
}

+(void)ringUpWithMobile:(NSString *)mobile
{
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",[mobile stringByReplacingOccurrencesOfString:@" " withString:@""]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
}
@end
